package com.stateflow.engine.user.web;

import com.stateflow.engine.user.biz.dto.req.QueryStateFlowReqDTO;
import com.stateflow.facade.common.model.res.CommonResult;
import com.stateflow.engine.user.biz.dto.req.RemoveStateFlowReqDTO;
import com.stateflow.engine.user.biz.dto.req.SubStateFlowReqDTO;
import com.stateflow.engine.user.biz.service.CRUDStateFlowService;
import com.stateflow.facade.common.util.CreateRequestUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created by weiqingming on 2019/12/6.
 * 增删改查用户状态流转模型
 */
@RestController
@RequestMapping(value = "/user/stateflow/")
public class CRUDStateFlowController {

    @Resource
    private CRUDStateFlowService CRUDStateFlowService;

    @RequestMapping(value = "createStateFlow.json",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult createStateFlow(@RequestBody SubStateFlowReqDTO param){
        return CRUDStateFlowService.createStateFlow(CreateRequestUtils.createByInside(param));
    }

    @RequestMapping(value = "modifyStateFlow.json",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult modifyStateFlow(@RequestBody SubStateFlowReqDTO param){
        return CRUDStateFlowService.modifyStateFlow(CreateRequestUtils.createByInside(param));
    }

    @RequestMapping(value = "removeStateFlow.json",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult removeStateFlow(@RequestBody RemoveStateFlowReqDTO param){
        return CRUDStateFlowService.removeStateFlow(CreateRequestUtils.createByInside(param));
    }

    @RequestMapping(value = "queryStateFlow.json",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult queryStateFlow(@RequestBody QueryStateFlowReqDTO param){
        return CRUDStateFlowService.queryStateFlow(CreateRequestUtils.createByInside(param));
    }
}
